package Day_Day_work;
 
import jdk.nashorn.internal.ir.ReturnNode;
 
import java.util.Scanner;

public class 回文日期 {
    public static void main(String[] args) {
        String[] B=A();
        System.out.println(B[0]);
        System.out.println(B[1]);
    }
    public static String []A(){
        Scanner scanner = new Scanner(System.in);
        int n =scanner.nextInt();
        String A[]=new String[2];
        int ans=0;
        int ans1=0;
        for (int i=n+1;i<=89991231;i++){
            String s=""+i;
            if(i%100<=31&&((i/100)%100==1||(i/100)%100==3||(i/100)%100==5||(i/100)%100==7||(i/100)%100==8||(i/100)%100==10||(i/100)%100==12)) {
                if (s.charAt(0) == s.charAt(7) && s.charAt(1) == s.charAt(6) && s.charAt(2) == s.charAt(5) && s.charAt(3) == s.charAt(4)) {
                    ans++;
                    if (ans == 1) A[0] = s;
                    if (s.charAt(0) == s.charAt(2) && s.charAt(1) == s.charAt(3)) {
                        ans1++;
                        if (ans1 == 1) A[1] = s;
                    }
                }
            }
            if(i%100<=27&&((i/100)%100<=12)) {
                if (s.charAt(0) == s.charAt(7) && s.charAt(1) == s.charAt(6) && s.charAt(2) == s.charAt(5) && s.charAt(3) == s.charAt(4)) {
                    ans++;
                    if (ans == 1) A[0] = s;
                    if (s.charAt(0) == s.charAt(2) && s.charAt(1) == s.charAt(3)) {
                        ans1++;
                        if (ans1 == 1) A[1] = s;
                    }
                }
            }
        }
        return A;
    }
}